package com.sanrenzu.chunbo.adapter;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.sanrenzu.chunbo.R;
import com.sanrenzu.chunbo.bean.zxb.XinXianTitleBean;

import java.util.List;

/**
 * Created by My on 2016/9/1.
 */
public class GengDuoGridView extends BaseAdapter {
    private List<XinXianTitleBean> list;
    private Context context;
    private LayoutInflater inflater;

    public GengDuoGridView(Context context,List<XinXianTitleBean> list){
        this.context=context;
        this.list=list;
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView( int position, View convertView, ViewGroup parent) {
        mViewHolder mHolder = null;
        if(convertView==null){
            convertView = inflater.inflate(R.layout.adapter_gengduo,parent,false);
            mHolder = new mViewHolder(convertView);
            convertView.setTag(mHolder);
        }else {
            mHolder = (mViewHolder) convertView.getTag();
        }


        mHolder.gengduo_title_adapter.setText(list.get(position).getTypeName());
        mHolder.gengduo_mingcheng_adapter.setText(list.get(position).getSunClassList().get(position).getSunClassName());
        mHolder.gengduo_image_adapter.setImageURI(Uri.parse(list.get(position).getSunClassList().get(position).getSunClassImage()+""));

        return convertView;
    }

    class mViewHolder {
        SimpleDraweeView gengduo_image_adapter;
        TextView gengduo_title_adapter;
        TextView gengduo_mingcheng_adapter;

        public mViewHolder(View convertView) {
            gengduo_image_adapter = (SimpleDraweeView) convertView.findViewById(R.id.gengduo_image_adapter);
            gengduo_title_adapter = (TextView) convertView.findViewById(R.id.gengduo_title_adapter);
            gengduo_mingcheng_adapter = (TextView) convertView.findViewById(R.id.gengduo_mingcheng_adapter);

        }
    }
}
